﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server.Dao;

namespace MaxStudio.Concrete.Server.Service
{
    public abstract  class ServiceHandle
    {
        private ConcreteDaoDataContext context;

        public void setContext(ConcreteDaoDataContext context)
        {
            this.context = context;
        }

        protected ConcreteDaoDataContext getDateContext()
        {
            if (this.context != null)
                return this.context;
            ConcreteDaoDataContext context = (ConcreteDaoDataContext)HttpContext.Current.Items[ConcreteConstants.USER_DATACONTEXT];
            if (context == null)
            {
                context = new ConcreteDaoDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ScottConnectionString"].ConnectionString);
                HttpContext.Current.Items[ConcreteConstants.USER_DATACONTEXT] = context;
            }
            return context;
        }

    }
}
